package com.mangguo.tingjian.account.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mangguo.tingjian.account.dto.RoleDto;
import com.mangguo.tingjian.account.mapper.RoleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class RoleService {

    @Resource
    private RoleMapper roleMapper;

    public List<RoleDto> findAllRole(){
        return roleMapper.selectList(new QueryWrapper<>()).stream()
                .map(role -> RoleDto.builder().id(role.getId()).name(role.getName()).build())
                .collect(Collectors.toList());
    }

}
